Repository navigation
test(cli): pin the three-probe restart acceptance for an API-created package - #20069
Merged
objectstack-fleet[bot] merged 1 commit intoSep 25, 2026
Merged
Conversation
…package Boots `os serve --dev` twice on one SQLite file, runs the create-package -> draft -> publish-drafts chain, and reads Studio's writable list, the data route and the published-object route before and after the restart. Claude-Session: https://claude.ai/code/session_01Bvd69VPa6puiNzzPUroDBx Co-authored-by: Claude <noreply@anthropic.com>
Contributor
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
This was referenced Sep 25, 2026
objectstack-fleet
Bot
deleted the
claude/issue-17676-package-restart-acceptance
branch
September 25, 2026 02:13
This was referenced Sep 25, 2026
akarma-synetal
pushed a commit
to akarma-synetal/framework
that referenced
this pull request
Sep 28, 2026
…ta back into the registry (objectstack-ai#20100) Fixes objectstack-ai#20071 Clause-②: no ## What was wrong `createStandaloneStack` (`packages/runtime/src/standalone-stack.ts`) is the composition behind `os dev` / `os serve` / `os start`. It stamps `environmentId: 'env_local'` (or whatever `OS_ENVIRONMENT_ID` names), and it built `new ObjectQLPlugin({ environmentId, runPlatformMigrations })` with no `hydrateMetadataFromDb`. `ObjectQLPlugin.start()` hydrates only `if (this.environmentId === undefined || this.hydrateMetadataFromDb)` (`packages/objectql/src/plugin.ts:767`). So every self-hosted boot: - skipped reading `sys_metadata`; - logged "Project kernel — skipping sys_metadata hydration (metadata sourced from artifact)". An object published at runtime then answered `404 OBJECT_NOT_FOUND` on the data API after a restart, while its row was still stored. This is the same deduction that the `[objectstack-ai#9380]` note in the same file records for `runPlatformMigrations`. ## The fix: a declaration, not a deduction - `createStandaloneStack` constructs `new ObjectQLPlugin({ environmentId, runPlatformMigrations: cfg.runPlatformMigrations ?? true, hydrateMetadataFromDb: true })`. The `[objectstack-ai#20071]` comment at that line carries the caution check below. - `StandaloneStackConfigSchema` and the published `StandaloneStackConfig` type are unchanged. - The only other edit in the file: objectstack-ai#9380's docblock pointer "line ~567 below" now reads "`createStandaloneStack` below". - `packages/objectql/**` and `packages/spec/**` are untouched. Opt-out: none. No caller of `createStandaloneStack` can make either clause of the caution false; adding a key later is its own card, declared `Clause-②: yes (widening)`. ## The plugin's caution, clause by clause The caution is on `ObjectQLPluginOptions.hydrateMetadataFromDb` (`plugin.ts:174-177`): "Set this ONLY when the kernel's registry is per-instance isolated AND `sys_metadata` lives on the kernel's own local driver (no control-plane proxy)". Both clauses are properties of `createStandaloneStack` itself, not of its caller. 1. **Per-instance isolated registry: holds.** - The function constructs a fresh `ObjectQLPlugin` and passes no `ql`, so `init()` runs `this.ql = new ObjectQL(hostCtx)` (`plugin.ts:397`). - Each `ObjectQL` owns its registry: `private _registry: SchemaRegistry = new SchemaRegistry();` (`engine.ts:3061`, whose comment says "Each engine now owns its registry so kernels are fully isolated"). - `SchemaRegistry` (`registry.ts:1819`) has no static members. 2. **`sys_metadata` on the kernel's own local driver: holds.** - `SysMetadataObject` (`packages/metadata-core/src/objects/sys-metadata.object.ts:17`) declares no `datasource`, so it routes to the default driver. - The function composes exactly one datasource, `DefaultDatasourcePlugin` as `default` (ADR-0062 D1: "every unbound object routes to it"). - Every `databaseDriver` kind the function dispatches (`memory`, `sqlite`, `sqlite-wasm`, `postgres`, `mysql`, `mongodb`, `turso`) is a direct driver, never a control-plane proxy. - The hydration read is `this.engine.find('sys_metadata', { where: { state: 'active', organization_id: null } })` (`loadMetaFromDb` in `packages/metadata-protocol/src/protocol.ts`), through that same engine. ## Stop valve: every caller of `createStandaloneStack`, measured `git grep createStandaloneStack` at `a4ca69a9` finds three production callers, plus tests and fixtures: | caller | what it is | `sys_metadata` | hydrates after this PR | |:--|:--|:--|:--| | `packages/cli/src/commands/serve.ts:2740` | `os serve` / `os dev` / `os start` with a config | the stack's own `default` driver | yes (declared) | | `packages/runtime/src/default-host.ts:163` (`createDefaultHostConfig`) | artifact-only boot | same | yes (declared) | | `packages/cli/src/utils/schema-migrate.ts:303` (`bootSchemaStack`) | the one-shot funnel for 13 `os migrate *` / `os meta *` commands | same | yes (declared), see below | | runtime and cli tests and fixtures | memory or sqlite files | same | yes (declared) | No caller has a proxied or non-local `sys_metadata`, so the stop valve does not fire. Outside this repository: - An org-wide code search for `createStandaloneStack` returns only `objectstack-ai/duly`: tests and seed scripts of an ordinary standalone app on its own database. - `objectstack-ai/cloud` is **NOT MEASURED**. Control leg: the same search for `hydrateMetadataFromDb` returns 0 hits outside this repository, although the plugin's own docblock says the cloud single-env tenant runtime sets that option. So the search cannot see that repository. - Either way, both caution clauses hold inside the function, so an unmeasured embedder gets the same composition. ## Why `bootSchemaStack` hydrates too Ruling ① lets a read-only one-shot boot turn hydration off "if it genuinely does not need it". Measured, the one-shots need it, or are neutral: - **`os migrate plan`:** its unmanaged-table sweep (`packages/cli/src/utils/unmanaged-tables.ts` header) says the question "is only answerable when the composed object set actually MIRRORS what this deployment's `os serve` boot registers". After this PR, `os serve` registers runtime-authored objects. - **`os migrate files-to-references`:** it refuses an empty scan because "this command's verdict is what later authorises irreversible behaviour". Without hydration it would silently skip the file fields of runtime-authored objects. - **The read writes nothing:** `loadMetaFromDb` is `engine.find` plus registry registration plus log lines. A boot that defers DDL still defers the Phase-3 tables of what it hydrated. - **Measured at `c945f282`:** `duplicates.integration.test.ts` (boot included, database byte-identical after the run), `platform-migrations-arming.integration.test.ts` and the six `schema-migrate*` / `unmanaged-tables` integration suites all pass. The stack's construction is the same `true` at the current head. ## Ruling ④: the false log line "Project kernel — skipping sys_metadata hydration" is now unreachable on this stack. It sits only in the `else` of the gate above, and `hydrateMetadataFromDb` is a literal `true` that no caller can change. The new unit test pins the flag under every way an environment id is stamped. Observed directly: - on the unfixed source, the unit test's two boots each printed that line once; - on the fix, the second boot prints `Metadata restored from database to SchemaRegistry {"loaded":2,"errors":0,"invalid":0}` and no skip line. No edit to `packages/objectql` was needed. ## Reach beyond one object (mechanism assumption 6) `packages/runtime/src/standalone-stack-hydrate-metadata.test.ts` boots the real stack twice on one SQLite file: - **Boot 1** writes an env-wide `object` row **and** an env-wide `app` row through the protocol, and inserts one record. - **Boot 2** has both rows in the registry, and the record reads back through the engine. The `app` is not in the registry on the boot that wrote it. On this composition, the protocol's write-through for non-object types returns early on a kernel with an environment id (see Acceptance notes). So boot hydration is the only thing that puts it there, which makes it a sharp second leg. Org-scoped rows are deliberately not asserted. `loadMetaFromDb` reads `organization_id IS NULL` only (ADR-0005: per-org overlays are served on demand). Diagnostics hydration now surfaces at boot, reported and not suppressed. `loadMetaFromDb` and its `reportUnhydratableOrgScopedRows` (objectstack-ai#6190) now run on every standalone boot: - a stored row that cannot register prints `[Protocol] [metadata_field_type_refused] …` at `error`, or `[Protocol] Failed to hydrate TYPE/NAME: …` / `[Protocol] [metadata_spec_invalid] …` at `warn`; - org-scoped rows of types that are not per-org overridable get one aggregated line. None of these fired in any suite run here. Against a real install's `sys_metadata` they are NOT MEASURED; the changeset names these lines for upgraders. ## The pin `packages/cli/test/package-restart-acceptance.integration.test.ts`: probe 2's `it.fails` is promoted to a plain `it`, and the file's header now describes the fixed state. A log-line assertion I added beside it was removed in this PR. The ablation leg showed it stays green on the unfixed build, because `os serve` does not print that INFO line at the pin's log level. ## Tests (head `46fd71b1`) - **The pin:** `pnpm --filter @objectstack/cli exec vitest run --project integration --maxWorkers=2 test/package-restart-acceptance.integration.test.ts` gives `Tests 5 passed (5)`. `ablation-dist-preflight` shows the runtime `dist` carries the literal. - **Unit test:** `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/standalone-stack-hydrate-metadata.test.ts` gives `Tests 2 passed (2)`. - **Runtime suite:** `pnpm --filter @objectstack/runtime test` gives `Test Files 279 passed (279)`, `Tests 3906 passed | 1 skipped (3907)`. - **Typecheck:** `pnpm --filter @objectstack/runtime typecheck` exits 0, with `check:test-typecheck: OK … 27 file(s) / 191 error(s) / 69 pinned signature(s)` (ledger unchanged). - **Lint:** full `pnpm lint` (`eslint . --no-inline-config`) exits 0. - **Gates:** all 60 commands that `node scripts/pm/dispatch-gates.mjs --commands` derives at `46fd71b1` exit 0. The `--ran` reconciliation reads "60 derived, 60 run, 0 NOT-MEASURED, 0 UNRUN". - **At `c945f282`**, before this revision: - the CLI unit project: `Test Files 224 passed (224)`, `Tests 3158 passed (3158)`; - `pnpm --filter @objectstack/cli typecheck`: exit 0; - CLI `--project integration` on 10 files (the pin, `duplicates`, `meta.stored-flow-resolution`, `platform-migrations-arming`, the five `schema-migrate*` files and `unmanaged-tables`): `Test Files 10 passed (10)`, `Tests 38 passed (38)`. This revision touches no CLI file, and the rest of the CLI integration project is declared to CI. **Ablation at `46fd71b1`, from committed state.** The mutation flipped the literal's `true` to `false` through `node scripts/ablation-replace.mjs`, anchored on the construction line. - **Mutation landed:** anchor x1 to x0, blob `b10937d6` to `dc0eab77`, and on-disk counts `true=0 false=1`. - **Reached `dist`:** after rebuilding `@objectstack/runtime`, `ablation-dist-preflight` reports the `true` spelling absent from all 6 dist files and the flipped spelling present in 2. - **Unit test:** 2 failed. The restart row fails at "hydr_widget is registered after the restart: expected undefined", the registry check just before its data read. - **Pin:** `1 failed | 4 passed`. Probe 2 fails with "GET /data/leave_request after a restart: {"error":"Object 'leave_request' is not registered","code":"OBJECT_NOT_FOUND"} … expected 404 to be 200". - **Restore:** - blob `b10937d6` == HEAD, and `git status --porcelain` is empty; - runtime rebuilt: the literal is present in 2 dist files and `false` absent from all 6; - the unit test gives 2 passed and the pin 5 passed. ## Acceptance notes (observations, not filed) - **Same deduction, non-object write-through:** `packages/metadata-protocol/src/protocol.ts` `applyRegistryWriteThrough` returns early for every non-object type when `this.environmentId !== undefined`. That is the same deduction class, one package over. On a standalone kernel, a runtime-saved `app` is absent from the registry on the boot that wrote it, until a listing or the next boot hydrates it; the new unit test's boot 1 measured this. No user-visible failure was measured, so it is recorded here, not filed. - **Comment drift:** `packages/objectql/src/plugin.ts` (the Phase-2 bridge comment) and `loadMetaFromDb`'s comment still call `SchemaRegistry` a process-wide singleton, while `engine.ts:3054-3061` says each engine now owns its own. Both files are read-only for this lane. ## Relations objectstack-ai#17676 remains open: that card belongs to the engine seat, and this PR delivers the runtime half that its acceptance pin (PR objectstack-ai#20069) waits on. --- _Generated by [Claude Code](https://claude.ai/code/session_01TnPAC1UsTGfHPXVUCL6iLn)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #17676 — ruling A′ item 5, the acceptance. #17676 remains open: at this head probe 2 disagrees after a restart, and its cause is in
packages/runtime(thedomain:clilane), outside this card's file surface.Clause-②: no
What this adds
packages/cli/test/package-restart-acceptance.integration.test.ts. This is a declared cross-lane, test-only edit: one new test file underpackages/cli, and no source change inpackages/cliorpackages/rest.os serve --devtwice on ONE SQLite file. The host app declares neithermarketplacenorpackage-registry(theexamples/app-crmshape), so this is the stock composition.POST /api/v1/packageswith the body Studio's create dialog sends, thenPUT /api/v1/meta/object/leave_request?mode=draft&package=com.example.leave, thenPOST /api/v1/packages/com.example.leave/publish-drafts. It reads the three probes, stops, boots again, and reads them again.test/helpers/serve-process.ts(CLI,TSX,childEnv,probeThroughChild, the port errors). It also follows the long-lived-boot pattern ofserve-package-registry-always-on.e2e.test.ts. That file'sbootServe/stopare file-local, so they are repeated here rather than lifted: lifting them would edit adomain:clifile outside this card's surface.The three probes, measured
GET /api/v1/packages, rows whosescopeis notsystem/cloudand whosewritableistruecom.example.leavelistedGET /api/v1/data/leave_requestOBJECT_NOT_FOUND—Object 'leave_request' is not registeredGET /api/v1/meta/object/leave_request/publishedWhere probe 1's route comes from. objectui at the pinned
.objectui-sha62597c58:packages/app-shell/src/views/studio-design/BuilderLanding.tsxrenders the headingengine.studio.landing.mineHeading("My packages (writable)", upper-cased by CSS) and the empty stateengine.studio.landing.noneWritable("No writable packages yet — create one to start.").fetchPackages()filtered towritable.studio-design/packages-io.tsfetchPackages()is ONE read,fetch('/api/v1/packages'), with no query parameters.parsePackagesdropsscope: system | cloudrows and reads the row's top-levelwritable.GET /packagesispackages/runtime/src/domains/packages.ts:registry.getAllPackages(), thenwithWritableVerdict.studioWritableIdsis that reader. It leaves out the client's fallback for servers that send nowritable.Why probe 2 disagrees: root cause, measured
servecomposition iscreateStandaloneStack(packages/runtime/src/standalone-stack.ts). It buildsnew ObjectQLPlugin({ environmentId, runPlatformMigrations })withenvironmentIddefaulting to'env_local'and nohydrateMetadataFromDb.ObjectQLPlugin.start()hydratessys_metadataonly whenenvironmentId === undefined || hydrateMetadataFromDb. Otherwise it logsProject kernel — skipping sys_metadata hydration (metadata sourced from artifact). A debug-level reboot on the same database file prints exactly that line.sys_metadatawithstate = active,organization_idNULL andpackage_id = com.example.leave. That is exactly whatloadMetaFromDbselects, but the row is never read. So the object is never re-registered and the data route answers 404, while the published read answers 200 straight off the stored row. ReadingGET /api/v1/meta/object/leave_requestand the object list on the live second boot does not change the 404.hydrateMetadataFromDb: trueto that constructor call and rebuilt@objectstack/runtime. On the same database file, probe 2 then answers 200 after the restart. Through this pin (leg B below), the other four assertions pass and theit.failsgoes red. So all three probes agree.packages/runtimeis thedomain:clilane, outside this card's file surface. The skip line's own words ("metadata sourced from artifact") are false on this composition, where runtime-authored metadata lives insys_metadata. That is part of the same defect, not a second one.How the agreement is pinned
it.fails, following the precedent inpackages/cli/test/commands.test.ts: known-broken, promote to a plain assertion once fixed.it.failsis green on ANY failure, so four harness-health assertions stand beside it: the chain lands (201 / 200 /outcome: 'published'), the three probes agree before the restart, probe 1 holds after it, and probe 3 holds after it.it, and it is the one that meets A writable package created viaPOST /api/v1/packagesis registered in memory only — it does not survive a restart, and leaves its published metadata orphaned #17676's acceptance.Tier
scripts/nightly-tiers.mjs). It spawns the CLI, sovitest-tiers.tsplaces it in theintegrationproject, and it runs in the per-PR and merge-queue Test Core.vitest list --filesOnly:--project integrationlists it 1 time and--project unit0 times. UnderOS_TEST_TIERS=nightlyit is listed 0 times; the control,serve-package-registry-always-on.e2e.test.ts, is listed 1 time.it.failsflips there rather than on a nightly after the change lands.Before / after (every run at
8af659d715, every mutation throughscripts/ablation-replace.mjs, each restore proven by blob equality with HEAD and an emptygit diff HEAD)it.fails(→it(in this fileGET /data/leave_request after a restart: {"error":"Object 'leave_request' is not registered","code":"OBJECT_NOT_FOUND","object":"leave_request"} (code OBJECT_NOT_FOUND): expected 404 to be 200; 4 passed'package-registry'key ofServe.CAPABILITY_PROVIDERSrenamed, so the key is absent.bin/run-dev.jsrunsserve.tsfromsrcthrough tsx, so there is no dist hopPackageServicePluginhydrateMetadataFromDb: trueincreateStandaloneStack, throughdist:@objectstack/runtimerebuilt,ablation-dist-preflightfinds the marker inindex.jsandindex.cjsit.failsis red withExpect test to failFor the restore,
@objectstack/runtimewas rebuilt from pristine source andablation-dist-preflight --absentexited 0 (the marker is absent from all 6 built files). It was checked again after the full package build below.Tests and gates (at
8af659d715)pnpm --filter @objectstack/cli exec vitest run --project integration --maxWorkers=2 test/package-restart-acceptance.integration.test.tsgives 1 file: 4 passed, 1 expected fail.pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2gives 224 files and 3158 tests passed. That includes the tier partition pintest/vitest-tiers-partition.test.ts.pnpm --filter @objectstack/cli typecheckexits 0. Thecheck:test-typecheckledger is unchanged (3 files / 28 errors / 6 signatures). The new file is in thetsconfig.test.jsonprogram (--listFiles: 1).eslint --no-inline-config --format jsonon the new file reports 1 file, 0 errors, 0 warnings. The population is eslint's own--print-configfor that file. Invariance: the config enables no type-aware linting (eslint.config.mjssays so, and the resolvedparserOptionscarry noproject), so adding one file cannot change any other file's verdict.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackfrom the real diff gives 48 commands, and all 48 finish at exit 0. Two were NOT MEASURED on the first pass:check:dual-build-cjs-loads(exit 3, PREREQUISITE NOT MET, 12 packages withoutdist) andcheck:type-check-debt(exit 124, my 280 s per-command timeout). Both exit 0 after a full package build (turbo, 72/72).--ranreports 48 derived, 48 run, 0 NOT-MEASURED, 0 UNRUN.node scripts/check-issue-citations.mjs --base 2274894ccexits 0 but reads 0 files.packages/**/*.test.tsis a declared deferred surface of that gate, so its green says nothing about this diff. The only number this file cites is A writable package created viaPOST /api/v1/packagesis registered in memory only — it does not survive a restart, and leaves its published metadata orphaned #17676.Changeset
None;
skip-changesetapplies.@objectstack/clishipsfiles: ["dist", "README.md", "CHANGELOG.md"]and builds fromsrc. Afterpnpm --filter @objectstack/cli build, a grep of those paths forstudioWritableIds/package-restart-acceptancefinds 0 files. The control,PackageServicePlugin, is found in 1distfile.Acceptance notes
PackageServicePluginonce, and the install logs no in-memory-only line.package 'com.example.leave' declares no engines.protocol range; rehydrating without a compatibility check (ADR-0087)for a package created with Studio's create-dialog body, which sends noengines. This is an observation and is not filed.bootServe/stopnow exist in twopackages/cli/testfiles (see above). Lifting them intotest/helpers/serve-process.tsis thedomain:cliseat's call.origin/mainmoved. It moved 5 commits since this branch's base2274894cc. The only overlap with the packages this pin exercises ispackages/objectql/src/validation/rule-validator.ts(validation-rule traversal), which is not the hydration seam. I did not mergemainin; the merge queue rebuilds on the currentmain.Generated by Claude Code